<%@ page language="java" contentType="text/html; charset=UTF-8" import="com.jd.po.User"
    pageEncoding="UTF-8"%>
    <%String path= "http://"+request.getHeader("host")+request.getContextPath(); %>
    <%User user = (User)session.getAttribute("user");
    String username = user.getUsername();
    String password = user.getPassword();
    
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>选择返回类型</title>
<script src="js/jQuery.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload= function() {
	getGroup();
}
function getGroup() {
	var group = document.getElementById("group");
	clearSel(group);
	var username = document.getElementById("Name").value;
	var url ="<%=path %>"+"/getGroupByAjax.action?username="+username;
   	$.ajax({
       	url: url,
      	dataType: 'text',
       	success: function(result) {
   			var arr = result.split(',');
   			setGroup(arr);
       	}
   });
}
function clearSel(oSelect){
	while(oSelect.childNodes.length>0){
		oSelect.removeChild(oSelect.childNodes[0]);
	}
}
function setGroup(result){
	var group = document.getElementById("group");
	$.each(result, function(i, area){
		var value = area;
		var text = area;
		var option = new Option(text,value);
		group.options.add(option);
	});
	
}
function submitForm() {
	
	var username = <%=username %>;
	var tOrb = $("input[@type=radio][@checked]").val();;
	var group = $('#group').val();
	var url ="<%=path %>"+"/reExtraction.action";
	$.post(url,{'username':username,'tOrb':tOrb,'group':group},function(result){
		if(result==''||result=='null') {
			alert("错误！");
		}else {
			window.returnValue=username+","+tOrb+","+group+","+result;
            window.close();
		}
	    });
}
</script>
</head>
<body>
<form name="form1" method="post" action="" id="form1">
                                <table width="265" border="0" align="center" cellpadding="0" cellspacing="0" class="table_user">
                                    <tr>
                                    <td height="30">
                                           	 组&nbsp;&nbsp;别
                                    </td> 
                                    <td align="left">
                                    	<input name="username" type="hidden" id="Name" value="<%=username %>" />
                                        <input name="password" type="hidden" id="Password" value="<%=password %>" />
                                    	<SELECT name="group" id="group" tabindex="2" class="input_text" >
                                    		<option value="" selected>请输入用户名</option>
                                    	</SELECT>
                                    </td>
                                    <td>
                                    <input type="button" name="Logon" value="" id="Logon" onclick="submitForm()" tabindex="3" class="but_login" />
                                  	</td>
                                    </tr>
                                    <tr>
                                    <td align="left" >
                                    	<input type="radio" id="tOrb1" name="tOrb" value="t" checked="checked" /><label for="tOrb1"><font style="font-size: 16px">主干</font></label>
                                    	<input type="radio" id="tOrb2" name="tOrb" value="b" /><label for="tOrb2"><font style="font-size: 16px">分支</font></label>
                                    </td>
                                    </tr>
                                </table>
    </form>
</body>
</html>